<?php
    include APPLICATION_PATH . '/application/views/head.phtml';
    include APPLICATION_PATH . '/application/views/top.phtml';
    include APPLICATION_PATH . '/application/views/left.phtml';
?>
<div id="thispage" data-id="53"></div>
<script >
$(document).ready(function() {
	var str = new Date().toLocaleDateString();
	//url.substring(0,str.lastIndexOf("/")+1);
	//alert(str.substring(str.lastIndexOf("/")+1));
	/*if(){

	}*/

	if(/\d{2}/g.test(str.substring(str.lastIndexOf("/")+1)) ==false) {
		str = str.substring(0,str.lastIndexOf("/")+1)+"0"+str.substring(str.lastIndexOf("/")+1);
	}
	$("#push_time_input").val(str.split("/").join("-")) ;
//alert(a);
	//alert(new Date().toLocaleDateString());
	$("#push_time_input").click(function(){
		$("#laydate_clear").click(function(){
			var user_id = $("#type_select").val();
			//alert(11);
			$.ajax({
					type: 'POST',
					url: '/Details/list' ,
					data: {"date":"","user_id":user_id},
					success: function(data) {
						var data = $.parseJSON(data);
		                $('#tbody').html('');
		                var id = '';
		                if(data != ""){
			                $.each(data, function(k, v) {
			                	var page       =  v['page'];
	                    		var rows       =  v['rows'];
	                    		var every_page =  v['every_page'];
			                	$('#tbody').append($('<tr class="gradeX"><td>' + v['user_name'] + '</td><td>' + v['site_name'] + '</td><td>' + v[0]['count'] + '</td><td>' + v['push_time'] + '</td></tr>'));
			                	if(rows/every_page<=1){
				                    $('#pages').html('');
				                }else{
				                    $('#pages').html(page);
				                }
			                });
		                }
		                else{
		                	 $('#pages').html('');
		                }
					}
				});
		return false;
		});
		$(".laydate_box tr td").each(function(){
			var user_id = $("#type_select").val();
			$(this).click(function(){
				if(/\d{2}/g.test($(this).attr("d")) ==false) {
					var date = $(this).attr("y")+"-"+$(this).attr("m")+"-0"+$(this).attr("d");
				}
				else{
					var date = $(this).attr("y")+"-"+$(this).attr("m")+"-"+$(this).attr("d");
				}
				
				$.ajax({
					type: 'POST',
					url: '/Details/list' ,
					data: {"date":date,"user_id":user_id},
					success: function(data) {
						var data = $.parseJSON(data);
		                $('#tbody').html('');
		                var id = '';
		                if(data != ""){
			                $.each(data, function(k, v) {
			                	var page       =  v['page'];
	                    		var rows       =  v['rows'];
	                    		var every_page =  v['every_page'];
			                	$('#tbody').append($('<tr class="gradeX"><td>' + v['user_name'] + '</td><td>' + v['site_name'] + '</td><td>' + v[0]['count'] + '</td><td>' + v['push_time'] + '</td></tr>'));
			                	if(rows/every_page<=1){
				                    $('#pages').html('');
				                }else{
				                    $('#pages').html(page);
				                }
			                });
		                }
		                else{
		                	 $('#pages').html('');
		                }
					}
				});
				return false;
			});
		});
		
	});

	$("#type_select").on('change', function(){
		var date = $("#push_time_input").val().split(" ")[0];
		//var user_id = $("#type_select").val();
		$.ajax({
					type: 'POST',
					url: '/Details/list' ,
					data: {"user_id":$(this).val(),"date":date},
					success: function(data) {
						var data = $.parseJSON(data);
		                $('#tbody').html('');
		                var id = '';
		                if(data != ""){
			                $.each(data, function(k, v) {
			                	var page       =  v['page'];
	                    		var rows       =  v['rows'];
	                    		var every_page =  v['every_page'];
			                	$('#tbody').append($('<tr class="gradeX"><td>' + v['user_name'] + '</td><td>' + v['site_name'] + '</td><td>' + v[0]['count'] + '</td><td>' + v['push_time'] + '</td></tr>'));
			                	if(rows/every_page<=1){
				                    $('#pages').html('');
				                }else{
				                    $('#pages').html(page);
				                }
			                });
		                }
		                else{
		                	 $('#pages').html('');
		                }
					}
				});
				return false;
	});




});
$(document).on('click', '#page_next,#page_prev,#page_index,#page_end', function() {
		var urlOld = $(this).attr('href'),
			urlArr = urlOld.split("/");
		urlId = urlArr[urlArr.length - 1];
		var date = $("#push_time_input").val().split(" ")[0];
		var user_id = $("#type_select").val();
		//alert(user_id);
		$.ajax({
			type: 'POST',
			url: '/Details/page/page/' + urlId,
			data: {"id":urlId,"date":date,"user_id":user_id},
			success: function(data) {
				var data = $.parseJSON(data);

				$('#tbody').html('');
				var id = '';

				$.each(data, function(k, v) {
					
					//console.log('k='+k);
					//id = v['article_type_id'];
					
					$('#tbody').append($('<tr class="gradeX"><td>' + v['user_name'] + '</td><td>' + v['site_name'] + '</td><td>' + v[0]['count'] + '</td><td>' + v['push_time'] + '</td></tr>'));


				});

			}

		});
		$.ajax({
			type: 'POST',
			url: '/Details/currentPage/page/' + urlId,
			data: {"id":urlId,"date":date,"user_id":user_id},
			success: function(data) {
				//console.log(data);
				$('#pages').html(data);
				$('#pages').ready(function() {
					nextBtn = $('#page_next');
				});
			}

		});
		return false;
	});
</script>		<!-- BEGIN PAGE -->

		<div class="page-content">

			<!-- BEGIN SAMPLE PORTLET CONFIGURATION MODAL FORM-->

			<div id="portlet-config" class="modal hide">

				<div class="modal-header">

					<button data-dismiss="modal" class="close" type="button"></button>

					<h3>portlet Settings</h3>

				</div>

				<div class="modal-body">

					<p>Here will be a configuration form</p>

				</div>

			</div>

			<!-- END SAMPLE PORTLET CONFIGURATION MODAL FORM-->

			<!-- BEGIN PAGE CONTAINER-->        

			<div class="container-fluid">

				<!-- BEGIN PAGE HEADER-->

				<div class="row-fluid">

					<div class="span12">

						<!-- BEGIN STYLE CUSTOMIZER -->

						<div class="color-panel hidden-phone">

							<!-- <div class="color-mode-icons icon-color"></div> -->

							<div class="color-mode-icons icon-color-close"></div>

							<div class="color-mode">

								<p>THEME COLOR</p>

								<ul class="inline">

									<li class="color-black current color-default" data-style="default"></li>

									<li class="color-blue" data-style="blue"></li>

									<li class="color-brown" data-style="brown"></li>

									<li class="color-purple" data-style="purple"></li>

									<li class="color-grey" data-style="grey"></li>

									<li class="color-white color-light" data-style="light"></li>

								</ul>

								<label>

									<span>Layout</span>

									<select class="layout-option m-wrap small">

										<option value="fluid" selected>Fluid</option>

										<option value="boxed">Boxed</option>

									</select>

								</label>

								<label>

									<span>Header</span>

									<select class="header-option m-wrap small">

										<option value="fixed" selected>Fixed</option>

										<option value="default">Default</option>

									</select>

								</label>

								<label>

									<span>Sidebar</span>

									<select class="sidebar-option m-wrap small">

										<option value="fixed">Fixed</option>

										<option value="default" selected>Default</option>

									</select>

								</label>

								<label>

									<span>Footer</span>

									<select class="footer-option m-wrap small">

										<option value="fixed">Fixed</option>

										<option value="default" selected>Default</option>

									</select>

								</label>

							</div>

						</div>

						<!-- END BEGIN STYLE CUSTOMIZER -->  

						<!-- BEGIN PAGE TITLE & BREADCRUMB-->

						<h3 class="page-title">

							用户报表

						</h3>

						<ul class="breadcrumb">

							<li>

								<i class="icon-home"></i>
								<span>当前位置：</span>
								<span>首页</span>

								<i class="icon-angle-right"></i>

							</li>

							<li>

								<span>报表管理</span>

								<i class="icon-angle-right"></i>

							</li>

							<li><span>用户报表</span></li>

						</ul>

						<div class="control-group clearfix">

                            <label class="control-label" style="float:left; line-height: 28px;">用户：</label>

                            <div class="controls" style="float:left;">
                    
                                <select class="small m-wrap" tabindex="1" id="type_select" >
                                    <option value="0" class="type" >选择推送的用户</option>
                  <?php 

                    foreach ($user_info as $key => $value) {
                        echo <<<EOF
                             <option value="{$value['user_id']}" class="type" data-id="{$value['user_id']}">{$value['realname']}</option>

EOF;
                    }
                                  
                  ?>
                                </select>

                            </div>
                            <label class="control-label" style="float:left; line-height: 28px; margin-left: 50px;">推送时间：</label>

                            <div class="controls" style="float:left;">

                                <label class="checkbox">

                                <div class="controls">
                                            
                                   <input placeholder="请输入日期" class="laydate-icon" onclick="laydate({istime: true, format: 'YYYY-MM-DD'})" id="push_time_input" name="push_time_input" value="请输入日期">

                                </div>

                                </label>

                                

                            </div>



						<!-- END PAGE TITLE & BREADCRUMB-->

					</div>

				</div>

				<!-- END PAGE HEADER-->

				<!-- BEGIN PAGE CONTENT-->

				<div class="row-fluid">

					<div class="span6 responsive" data-tablet="span12 fix-offset" data-desktop="span6" style="width:100%;">

						<!-- BEGIN EXAMPLE TABLE PORTLET-->

						<div class="portlet box grey">

							<div class="portlet-title">

								<div class="caption"><i class="icon-user"></i>用户报表</div>

								<div class="actions controls">

								</div>

							</div>

							<div class="portlet-body">

                                <table class="table table-striped table-bordered table-hover" id="current_table">

                                    <thead>

                                        <tr>
                                            <th>用户名</th>
                                            <th>推送网站</th>
                                            <th>推送数量</th>
                                            <th>推送时间</th>
                                        </tr>

                                    </thead>
                				<tbody id="tbody">
<?php
    foreach ($pushUserAboutInfo as $k => $v) {
    	/*echo "<pre>";
var_dump($v);*/
        $style = (0 == ($k % 2)) ? 'odd' : 'even';
        echo <<< EOF
                                        <tr class="{$style} gradeX">

                                            <td>{$v['user_name']}</td>
                                            <td>{$v['site_name']}</td>
                                            <td>{$v[0]['count']}</td>
                                            <td>{$v['push_time']}</td>
                                        </tr>
EOF;
    }
?>
                                    </tbody>

                </table>

               <!--  <p><a href="#" id="chose1">全选</a> / <a href="#" id="chose2">反选</a></p> -->

<div id="pages">
<?php
    if($pushUserAboutInfo[0]['rows']/$pushUserAboutInfo[0]['every_page']<=1 || empty($pushUserAboutInfo))
    {
        
    }
    else
    {
        print_r($allpage);
    }
       
?>
</div>
		
							</div>

						</div>
						

					</div>

				</div>

				<!-- END PAGE CONTENT-->

			</div>

			<!-- END PAGE CONTAINER-->

		</div>
<script >

</script >
<?php
    include APPLICATION_PATH . '/application/views/foot.phtml';
?>